﻿using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;
using VideoClassLibrary.Model;
using VideoClassLibrary.BusinessLogicLayer;
public partial class Report_VideoViewDetailPagedByPro : AdminUserBase
{
    public string ViewUsereListHtml;
    public  int courseid;  
   
    protected void Page_Load(object sender, EventArgs e)
    {
     
        if (!IsPostBack)
        { 
            courseid= Convert.ToInt32(Request.QueryString["courseid"].ToString());
            Bind();
            CreateHtml();
        }
    }
     private void Bind()
      {
         Pager p=new Pager();
         p.PageIndex = PageIndex;//当前页
         p.PageSize = 15;//每页中显示的数据数
         p.TableName = "UserViewRepurteUserList";//用来分页的表名
         p.Order = "ID";//排序的字段
         p.OrderType = false;//排序规则
         p.SelectStr = " ID, UserID, UserName, View_time, courselistID, SchoolID, VS_name, VU_loginname, VU_mobile, VU_email, IsAvailable ";//所要检索的数据字段
       
         //int courseid = 23;
         //int SchoolID = 1;
         if (this.SchoolID != 0)
          {
              p.WhereCondition = " SchoolID=" + this.SchoolID.ToString() + " and courselistID=" + courseid.ToString();//检索条件
         }
         VideoCommentModule vm= new VideoCommentModule();
         Repeater1.DataSource = vm.GetVideoViewListByPro( p);
         Repeater1.DataBind();
         this.maxPage = p.PageCount;//页总数
         this.rowsCount = p.RecordCount;//总数据数
     }
     private int rowsCount;
     protected int RowsCount
     {
         get { return rowsCount; }
         set { rowsCount = value; }
     }

     private int maxPage;
     protected int MaxPage
     {
         get { return maxPage; }
         set { maxPage = value; }
     }
     private int pageIndex;
     protected int PageIndex
     {

         get
         {
             if (Request["CurrentPage"] == null)
             {
                 pageIndex = 1;
             }
             else
             {
                 pageIndex = Int32.Parse(Request["CurrentPage"]);
             }

             return pageIndex;
         }
        
     }
     private void CreateHtml()
     {
         ViewUsereListHtml = "";
         for (int i = 1; i <= maxPage; i++)
         {
             ViewUsereListHtml += " <a href='?CurrentPage=" + i + "&courseid=" + courseid + "'>" + i + "</a> ";
             //if (i == 1)
             //{
             //    this.prepage.Disabled = true;
             //}
             //else if (i == maxPage)
             //{ this.nextpage.Disabled = true; }

         }

     }

}
